/*
 * @Author: lls 1445622103@qq.com
 * @Date: 2024-04-21 14:19:13
 * @LastEditors: lls 1445622103@qq.com
 * @LastEditTime: 2024-04-21 14:20:40
 * @FilePath: /my-vue-app/vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import { nodePolyfills } from 'vite-plugin-node-polyfills';

// https://vitejs.dev/config/
export default defineConfig({
  define: {// 将 global 定义为 window
        process: {
      env: {
        NODE_ENV: 'development', // 或者 'production'
      },
    },
  },
  build: {
    rollupOptions: {
      output: {
        manualChunks: (path) => {
          if (path.includes("node_modules")) {
            return "node"
          }
        }
      }
    }
  },
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue'], // 自动导入 Vue 3 的 API
      dts: 'src/auto-imports.d.ts', // 自动生成类型定义
    }),
        Components({
      resolvers: [VantResolver()], // 配置 Vant 组件按需引入
    }),
    // nodePolyfills(),
  ],
  server:{
    open:true
  },
})
